<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <link rel="shortcut icon" type="image/ico" href="{{asset('/favicon.ico')}}">
    <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <meta name="keywords" content="{{\Illuminate\Support\Facades\Config::get('web.keywords')}}" />
    <meta name="description" content="{{\Illuminate\Support\Facades\Config::get('web.describe')}}" />
    <link rel="stylesheet" href="{{asset('assets/css/amazeui.min.css')}}">
    <link rel="stylesheet" href="{{asset('assets/css/wap.css')}}">
    <title>首页</title>
    <link rel="stylesheet" type="text/css" href="{{asset('assets/css/search-normalize.css')}}" />
    <link rel="stylesheet" href="{{asset('assets/css/font-awesome.min.css')}}">
    <link rel="stylesheet" href="{{asset('assets/css/search-style.css')}}">
    <link rel="stylesheet" href="{{asset('assets/css/loader.css')}}">
    <script src="{{asset('assets/js/jquery.min.js')}}"></script>
    <script>
        // 等待所有加载
        $(window).load(function(){
            $('body').addClass('loaded');
            $('#loader-wrapper .load_title').remove();
        });
    </script>
    <script>
        document.addEventListener("plusready", function() {
            // 注册返回按键事件
            plus.key.addEventListener('backbutton', function() {
                // 事件处理
                plus.nativeUI.confirm("退出程序？", function(event) {
                    if (event.index) {
                        plus.runtime.quit();
                    }
                }, null, ["取消", "确定"]);
            }, false);
        });
    </script>
</head>
<body>
<div data-am-widget="gotop" class="am-gotop am-gotop-fixed">
    <a href="#top" title="">
        <img class="am-gotop-icon-custom" src="{{asset('assets/images/home/goTop.png')}}" />
    </a>
</div>
<div id="loader-wrapper">
    <div id="loader"></div>
    <div class="loader-section section-left"></div>
    <div class="loader-section section-right"></div>
    <div class="load_title">请稍等哦(๑•̀ㅂ•́)و✧</div>
</div>
<span onclick="testt()" class="icon-search" style=" bottom:60px; position:fixed;right:10px;width: 30px;;background-color: #0dc6d4;z-index: 986785;padding: 6px 6px 6px 7px;font-weight: bold;color: whitesmoke">

</span>
<div class="pet_mian" id="top">
    <div data-am-widget="slider" class="am-slider am-slider-a1" data-am-slider='{"directionNav":false}' >
        <ul class="am-slides">
            @foreach($bannerArticle as $ba)
                <li><a href="{{url('articledetail/'.$ba['id'])}}">
                        <img src="{{$ba['banner']}}-800X375">
                        <div class="pet_slider_font">
                    <span class="pet_slider_emoji">作者:
                        @if(empty($ba['username']))
                            大佬
                        @else
                            {{$ba['username']}}
                        @endif
                    </span>
                            <span>{{$ba['title']}}</span>
                        </div>
                        <div class="pet_slider_shadow"></div></a>
                </li>
            @endforeach
        </ul>
    </div>
    <div class="pet_circle_nav">
        <ul class="pet_circle_nav_list">
            <li><a href="{{url('imagelist/1')}}" class="iconfont pet_nav_xinxianshi ">&#xe61e;</a><span>图片</span></li>
            <li><a href="{{url('articlelist/1')}}" class="iconfont pet_nav_kantuya ">&#xe62c;</a><span>阅读</span></li>
            <li><a href="{{url('usercenter')}}" class="iconfont pet_nav_zhangzhishi ">&#xe607;</a><span>个人中心</span></li>
            <li><a href="javascript:;" class="iconfont pet_nav_gengduo ">&#xe600;</a><span>更多</span></li>
        </ul>
        <div class="pet_more_list" style="height: 100%">
            <div class="pet_more_list_block">
                <div class="iconfont pet_more_close">×</div>
                <div class="pet_more_list_block">
                    <div class="pet_more_list_block_name">
                        <div class="pet_more_list_block_name_title">文章类</div>
                        @foreach($Num[6][1] as $v)
                            <a class="pet_more_list_block_line" href="{{url('articlelist/1/'.$v['id'])}}">
                                <div class="pet_more_list_block_line_font">{{$v['category']}}</div>
                            </a>
                        @endforeach
                        <div class="pet_more_list_block_name_title">图片类</div>
                        @foreach($Num[6][2] as $v)
                            <a class="pet_more_list_block_line" style="text-align: center;" href="{{url('imagelist/1/'.$v['id'])}}">
                                <div class="pet_more_list_block_line_font">{{$v['category']}}</div>
                            </a>
                        @endforeach


                        <div class="pet_more_list_block_name_title pet_more_list_block_line_height">服务 Service</div>
                        @if(!Session::get('user'))
                            <a class="pet_more_list_block_line" href="{{url('login')}}">
                                {{--<i class="iconfont pet_nav_xinxianshi pet_more_list_block_line_ico">&#xe61e;</i>--}}
                                <div class="pet_more_list_block_line_font">登录</div>
                            </a>
                            <a class="pet_more_list_block_line" href="{{url('forget')}}">
                                <!-- <i class="iconfont pet_nav_kantuya pet_more_list_block_line_ico">&#xe62c;</i> -->
                                <div class="pet_more_list_block_line_font">忘记密码</div>
                            </a>
                            <a class="pet_more_list_block_line" href="{{url('register')}}">
                                {{--<i class="iconfont pet_nav_zhangzhishi pet_more_list_block_line_ico">&#xe607;</i>--}}
                                <div class="pet_more_list_block_line_font">注册</div>
                            </a>
                        @else
                            <a class="pet_more_list_block_line" href="{{url('usercenter')}}">
                                {{--<i class="iconfont pet_nav_zhangzhishi pet_more_list_block_line_ico">&#xe607;</i>--}}
                                <div class="pet_more_list_block_line_font">个人中心</div>
                            </a>
                            <a class="pet_more_list_block_line" href="{{url('logout')}}">
                                {{--<i class="iconfont pet_nav_zhangzhishi pet_more_list_block_line_ico">&#xe607;</i>--}}
                                <div class="pet_more_list_block_line_font">退出登录</div>
                            </a>
                        @endif
                        <a class="pet_more_list_block_line" data-am-modal="{target: '#doc-modal-1', closeViaDimmer: 0, width: 330, height: 245}">
                            {{--<i class="iconfont pet_nav_zhangzhishi pet_more_list_block_line_ico">&#xe607;</i>--}}
                            <div class="pet_more_list_block_line_font">问题反馈</div>
                        </a>
                    </div>
                </div>

            </div></div>
    </div>
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="doc-modal-1" style="z-index: 999999999;">
        <div class="am-modal-dialog">
            <div class="am-modal-hd"><span id="commentTitle">问题反馈</span>
                <a href="javascript: void(0)" class="am-close am-close-spin" data-am-modal-close>&times;</a>
            </div>
            <input type="hidden" name="cid" value="">
            <div class="am-modal-bd">
                <div class="am-form-group">
                    <textarea class="sgfTextarea" rows="5" style="width:100%" id="dodfhd" style="border: beige;"></textarea>
                </div>
                <a class="am-btn am-btn-xs am-btn-danger" style="float: left;margin-left: 15%;" data-am-modal-close>取消</a>
                <button class="am-btn am-btn-xs am-btn-primary" onclick="postfan()" style="float: right;margin-right: 15%;">提交</button>
            </div>
        </div>
    </div>
    <div class="pet_content_main">
        <div data-am-widget="list_news" class="am-list-news am-list-news-default" >
            <div class="am-list-news-bd">
                <ul class="am-list" id="main_listjh">
                    <!--缩略图在标题右边-->
                    @foreach($mainContent as $m)
                        @if(isset($m->banner))
                            {{--文章--}}
                            <li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right pet_list_one_block">
                                <div class="pet_list_one_info">
                                    <div class="pet_list_one_info_l">
                                        <div class="pet_list_one_info_ico"><img src="
                                @if(empty($m->avatar))
                                            {{asset('assets/images/home/a1.png')}}
                                            @else
                                            {{$m->avatar}}-40X40
                                                    @endif
                                                    " alt=""></div>
                                        <div class="pet_list_one_info_name">
                                            @if(empty($m->username))
                                                大佬
                                            @else
                                                {{$m->username}}
                                            @endif
                                        </div>
                                        <small> &nbsp;&nbsp;{{date('Y-m-d H:i:s',$m->created_at)}}发布</small>
                                    </div>
                                    <div class="pet_list_one_info_r">
                                        <div class="pet_list_tag pet_list_tag_xxs">{{$m->category}}</div>
                                    </div>
                                </div>
                                <div class=" am-u-sm-8 am-list-main pet_list_one_nr">
                                    <h3 class="am-list-item-hd pet_list_one_bt"><a href="{{url('articledetail/'.$m->id)}}" class="">{{$m->title}}</a></h3>
                                    <div class="am-list-item-text pet_list_one_text">
                                        {{$m->content}}
                                    </div>

                                </div>
                                <div class="am-u-sm-4 am-list-thumb">
                                    <a href="{{url('articledetail/'.$m->id)}}" class="">
                                        @if(!empty($m->cover))
                                            <img src="{{$m->cover}}-300X230" class="pet_list_one_img" style="height: 76px;width: 100px;" alt=""/>
                                        @else
                                            <img src="{{asset('assets/images/home/q4.jpg')}}" class="pet_list_one_img" style="height: 76px;width: 100px;" alt=""/>
                                        @endif
                                    </a>
                                </div>
                            </li>
                        @endif
                        @if(isset($m->images))
                            {{--图集--}}
                            <li class="am-g am-list-item-desced pet_list_one_block">
                                <div class="pet_list_one_info">
                                    <div class="pet_list_one_info_l">
                                        <div class="pet_list_one_info_ico"><img src="
                                @if(empty($m->avatar))
                                            {{asset('assets/images/home/a1.png')}}
                                            @else
                                            {{$m->avatar}}-40X40
                                                    @endif
                                                    " alt=""></div>
                                        <div class="pet_list_one_info_name">
                                            @if(empty($m->username))
                                                大佬
                                            @else
                                                {{$m->username}}
                                            @endif
                                        </div>
                                        <small> &nbsp;&nbsp;{{date('Y-m-d H:i:s',$m->created_at)}}发布</small>
                                    </div>
                                    <div class="pet_list_one_info_r">
                                        <div class="pet_list_tag pet_list_tag_kty">{{$m->category}}</div>
                                    </div>
                                </div>
                                <div class=" am-list-main">
                                    <h3 class="am-list-item-hd pet_list_one_bt"><a href="{{url('imagedetail/'.$m->id)}}" class="">{{$m->title}}</a></h3>
                                    <ul data-am-widget="gallery" class="am-gallery am-avg-sm-3 am-avg-md-3 am-avg-lg-3 am-gallery-default pet_list_one_list pet_list_one_tytj" >
                                        @foreach(json_decode($m->images) as $k=>$image)
                                            @if($image!='undefined')
                                                @if($k<6)
                                                    <li>
                                                        <div class="am-gallery-item">
                                                            <a href="{{url('imagedetail/'.$m->id)}}" class="">
                                                                <img src="{{$image}}-300X230"  alt="图片" style="height: 81px;width: 106px;" />
                                                            </a>
                                                        </div>
                                                    </li>
                                                @endif
                                            @endif
                                        @endforeach
                                    </ul>
                                </div>
                            </li>
                        @endif
                    @endforeach

                </ul>
            </div>

        </div>

    </div>
    <div class="pet_article_dowload pet_dowload_more_top_off">

        <div class="pet_article_dowload_title" style="text-align: center">
            <button type="button" id="more" class="am-btn am-btn-default am-btn-block"
                    data-am-loading="{spinner: 'circle-o-notch', loadingText: 'loading...', resetText: '加载更多'}">加载更多</button>
        </div>
        <div class="pet_article_footer_info">{{\Illuminate\Support\Facades\Config::get('web.binfo')}}</div>
    </div>
</div>
<script src="{{asset('assets/js/amazeui.min.js')}}"></script>
<script type="text/javascript" src="{{asset('assets/layer/layer.js')}}"></script>
<script>
    page=2;
    $('#more').click(function () {
        var $btn = $(this);
        $btn.button('loading');
        $.get('{{url('indexlist')}}/'+page, function (res) {
            page+=1;
            /************处理显示数据*************/
            html="";

            $.each(res,function(i,item){
                if(item.avatar==null){
                    console.log(item.avatar);
                    avatar='{{asset('assets/images/home/a1.png')}}';
                }else{
                    avatar=item.avatar+'-40X40';
                }
                if(item.username==null){
                    username='大佬';
                }else{
                    username=item.username;
                }
                if(typeof (item.content)=='undefined'){
                    html+='<li class="am-g am-list-item-desced pet_list_one_block"><div class="pet_list_one_info"><div class="pet_list_one_info_l"><div class="pet_list_one_info_ico"><img src="'
                    html+=avatar+'"></div><div class="pet_list_one_info_name">';
                    cate=item.category;
                    url='{{url('imagedetail')}}/'+item.id;
                }else if(typeof (item.images)=='undefined'){
                    html+='<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right pet_list_one_block"><div class="pet_list_one_info"><div class="pet_list_one_info_l"><div class="pet_list_one_info_ico"><img src="'
                    html+=avatar+'"></div><div class="pet_list_one_info_name">';
                    cate=item.category;
                    url='{{url('articledetail')}}/'+item.id;
                }

                if(typeof (item.images)=='undefined'){
                    html+=username+'</div><small> &nbsp;&nbsp; '+getDate(item.created_at)+'发布</small></div><div class="pet_list_one_info_r">' +
                            '<div class="pet_list_tag pet_list_tag_xxs">' +cate +
                            '</div></div></div><div class=" am-u-sm-8 am-list-main pet_list_one_nr"><h3 class="am-list-item-hd pet_list_one_bt">' +
                            '<a href="'+url+'" class="">'+item.title+'</a></h3>';
                    html+='<div class="am-list-item-text pet_list_one_text">';
                    content=item.content;
                    html+=content+'</div></div><div class="am-u-sm-4 am-list-thumb"><a href="';
                    html+='{{url('articledetail')}}/'+item.id+'" class="">';
                    if(item.cover==''){
                        cover='{{asset('assets/images/home/q4.jpg')}}';
                    }else{
                        cover=item.cover+'-300X230';
                    }
                    html+='<img src="'+cover+'" class="pet_list_one_img" style="height: 76px;width: 100px;" /></a></div></li>'
                }else if(typeof (item.content)=='undefined'){
                    html+=username+'</div><small> &nbsp;&nbsp; '+getDate(item.created_at)+'发布</small></div><div class="pet_list_one_info_r">' +
                            '<div class="pet_list_tag pet_list_tag_kty">' +cate +
                            '</div></div></div><div class="am-list-main"><h3 class="am-list-item-hd pet_list_one_bt">' +
                            '<a href="'+url+'" class="">'+item.title+'</a></h3>';
                    html+='<ul data-am-widget="gallery" class="am-gallery am-avg-sm-3 am-avg-md-3 am-avg-lg-3 am-gallery-default pet_list_one_list pet_list_one_tytj" >';
                    images=$.parseJSON(item.images);
                    $.each(images,function(i,img){
                        if(i<6){
                            html+='<li><div class="am-gallery-item"><a href="'+'{{url('imagedetail')}}/'+item.id+'" class=""><img src="'
                                    +img+'-300X230"  alt="图片" style="height: 81px;width: 106px;" /></a></div></li>'
                        }
                    });
                    html+='</ul></div></li>';
                }
            });
            if(html!=''){
                $("#main_listjh").append(html);
                sdgs();
                $btn.button('reset');
            }else{
                $btn.button('reset');
                layer.msg('没有啦-_-!!');
            }
        });
    });

    function getDate(timeLog) {
        var date = new Date(timeLog*1000);
        Y = date.getFullYear() + '-';
        M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
        D = (date.getDate()<10?'0' +date.getDate():date.getDate())+ ' ';
        h = (date.getHours()<10?'0'+date.getHours():date.getHours()) + ':';
        m = (date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes()) + ':';
        s = (date.getSeconds()<10?'0'+date.getSeconds():date.getMinutes());
        return Y+M+D+h+m+s;
    }

    function sdgs(){
        // 动态计算新闻列表文字样式
        auto_resize();
        $(window).resize(function() {
            auto_resize();
        });
        $('.am-list-thumb img').load(function(){
            auto_resize();
        });

        $('.am-list > li:last-child').css('border','none');
        function auto_resize(){
            $('.pet_list_one_nr').height($('.pet_list_one_img').height());

        }
        $('.pet_nav_gengduo').on('click',function(){
            $('.pet_more_list').addClass('pet_more_list_show');
        });
        $('.pet_more_close').on('click',function(){
            $('.pet_more_list').removeClass('pet_more_list_show');
        });
    }

    $(function(){
        sdgs();
    });
    function postfan(){
        var q=$("#dodfhd").val();
        $.post('{{url('admin/addquestion')}}',{'_token':'{{csrf_token()}}','question':q}, function (res) {
            if(res.status){
                $('#doc-modal-1').modal('close');
                layer.msg(res.msg);
            }else{
                alert(res.msg);
            }
        });
    }

    function testt(){
        //页面层-自定义
        layer.open({
//            scrollbar: false,
            type: 1,
            title: false,
            closeBtn: 0,
            offset: '100px',
            shadeClose: true,
            skin: 'yourclass',
            content: '<div class="search d1"><form action="{{url('search')}}" method=\'get\'><input type="text" name="title" autofocus="autofocus" placeholder="搜索从这里开始..."><button type="submit"></button></form></div>'
        });
    }
</script>
</body>
</html>